﻿@{
    ViewBag.Title = "微信登录";
    var scan = Request.RequestContext.RouteData.Values["id"].xTrim();
    if (scan.Length <= 0)
    {
        Html.RenderPartial("Result", new YYS.ResultModel() { IsPart = 1, Icon = 5, Msg = "缺少必须的参数", Title = "提示" });
        return;
    }
    var json = scan.xFromSafeBase64().xAESDecrypt(YYS.DefaultValue.EnvAESKey).xConvertToJObject();
    var account = json.Value<string>("account");
    var pwd = json.Value<string>("pwd");
    var time = json.Value<DateTime>("time");
    TimeSpan hoursSpan = new TimeSpan(DateTime.Now.Ticks - time.Ticks);
    if (hoursSpan.TotalMinutes > 30)
    {
        Html.RenderPartial("Result", new YYS.ResultModel() { IsPart = 1, Icon = 5, Msg = "链接已过期", Title = "登录失败", AutoURL = Url.Content("~/pc/Login"), AutoTimeout = 3 });
        return;
    }
    var data = YYS.Controllers.pcController._webLogin(account, pwd);
    if (!string.IsNullOrWhiteSpace(data.Error)) {
        Html.RenderPartial("Result", new YYS.ResultModel() { IsPart = 1, Icon = 5, Msg = data.Error, Title = "登录失败", AutoURL = Url.Content("~/pc/Login"), AutoTimeout = 3 });
        return;
    }
    var openkey = data.Obj.openkey.xTrim();
    Html.RenderPartial("Result", new YYS.ResultModel() { IsPart = 1, Icon = 1, Msg = "正在跳转页面，请稍后...", AutoURL = Url.Content("~/pc/index?key="+ openkey.xToBase64())});
    //http://127.0.0.1/api/pc/WxMpLogin/x_r2UUFO9cAEpTCoQgxcW1_vtJp3GaDFR0LjDnnJQVnDWlhXWR3KpLV4HMZfKeam
}

<div id="app" class="flex-column h100 hidden">
    <div class="flex-row h100" style="align-items:flex-start;">
        <div class="flex-row-fill flex-column bg-light">
            <div class="flex-column-fill hidden-x">
                <js-media-detail v-if="!!msgInfo" :preview="false" :value="msgInfo"></js-media-detail>
                <el-empty v-else :image-size="200" class="h100" description="暂无预览"></el-empty>
            </div>
        </div>
    </div>
</div>

@section script{

}
@section body{
    @*@System.Web.Optimization.Scripts.Render("~/Content/pc/helper.share")*@
    @*<script src="@Url.Content("~/Views/pc/My/Component/helper.share.js")"></script>*@
}
